<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="model.*"%>
<%@ page import="dao.*"%>
<%@ page import="java.util.*"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%
	Tourist tourist1 = (Tourist) session.getAttribute("tourist");
	if (tourist1 == null) {
		response.sendRedirect("Login.html");
	} else {
		Tourist tourist = TouristDao.getTouristNoCache(tourist1.getEmail());
		List<Horder> horders = new ArrayList<Horder>();
		horders = tourist.getHorders();
		List<Hotel> hotels = new ArrayList<Hotel>();
		for (Horder horder : horders) {
			Hotel hotel = new Hotel();
			hotel = HotelDao.getHotelNoCache(horder.getId().getHEmail());
			hotels.add(hotel);
		}
		
		List<Rorder> rorders = new ArrayList<Rorder>();
		rorders = tourist.getRorders();
		List<Route> routes = new ArrayList<Route>();

		for (Rorder rorder : rorders) {
			Route route = new Route();
			route = RouteDao.getRouteNoCache(rorder.getId().getRName());
			routes.add(route);
		}

		pageContext.setAttribute("hotels", hotels);
		request.setAttribute("tourist1", tourist1);
		String t1 = "11";
		pageContext.setAttribute("t1", t1);
		pageContext.setAttribute("routes", routes);
	}
%>
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8" />
<title>Home</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1" name="viewport" />
<meta content="" name="description" />
<meta content="" name="author" />
<link
	href="http://fonts.googleapis.com/css?family=Hind:300,400,500,600,700"
	rel="stylesheet" type="text/css">
<link href="vendor/simple-line-icons/simple-line-icons.min.css"
	rel="stylesheet" type="text/css" />
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet"
	type="text/css" />
<link href="css/animate.css" rel="stylesheet">
<link href="vendor/swiper/css/swiper.min.css" rel="stylesheet"
	type="text/css" />

<!-- THEME STYLES -->
<link href="css/layout.min.css" rel="stylesheet" type="text/css" />

<!-- Favicon -->
<link rel="shortcut icon" href="favicon.ico" />
</head>
<!-- END HEAD -->
<style>
.table{
table-layout: fixed;
}
</style>
<!-- BODY -->
<body id="body" data-spy="scroll" data-target=".header">

	<jsp:include page="Header.jsp" flush="true"></jsp:include>


	<!-- Latest Products -->
	<div id="我的订单">
		<div class="content-lg container">
			<div class="row margin-b-40">
				<div class="col-sm-6">
					<h2>我的订单</h2>
					<h3>尊敬的用户：${tourist1.name }</h3>
				</div>
			</div>
			<!--// end row -->

			<div class="row">
				<table class="table table-bordered mtable2" width="100%"
					cellspacing="0">
					<thead>
						<tr>
							<th>序号</th>
							<th>酒店</th>
							<th>价格</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach var="hotel" items="${pageScope.hotels }"
							varStatus="status">
							<tr>
								<td>${status.index +1}</td>
								<td>${hotel.name }</td>
								<td>${hotel.price }</td>
								<td><a
									href="javascript:if(confirm('确定要删除该订单吗?'))location='<%=request.getContextPath()%>/HorderServlet?hemail=${hotel.email }&handle=delHorder'">删除酒店</a></td>
							</tr>

						</c:forEach>
					</tbody>
				</table>

				<table class="table table-bordered mtable2" width="100%"
					cellspacing="0">
					<thead>
						<tr>
							<th>序号</th>
							<th>路线</th>
							<th>价格</th>
						
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach var="route" items="${pageScope.routes }"
							varStatus="status">
							
							<tr>
								<td>${status.index +1}</td>
								<td>${route.rcname }</td>
								<td>${route.money }</td>
								
								<td><a
									href="javascript:if(confirm('确定要删除该订单吗?'))location='<%=request.getContextPath()%>/RorderServlet?rname=${route.rname }&handle=delRorder'">删除路线</a></td>
							</tr>

						</c:forEach>
					</tbody>
				</table>
			</div>
			<!--// end row -->
		</div>
	</div>
	<!-- End Latest Products -->

	<jsp:include page="Footer.jsp" flush="true"></jsp:include>

	<!-- Back To Top -->
	<a href="javascript:void(0);" class="js-back-to-top back-to-top">Top</a>

	<!-- JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
	<!-- CORE PLUGINS -->
	<script src="vendor/jquery.min.js" type="text/javascript"></script>
	<script src="vendor/jquery-migrate.min.js" type="text/javascript"></script>
	<script src="vendor/bootstrap/js/bootstrap.min.js"
		type="text/javascript"></script>

	<!-- PAGE LEVEL PLUGINS -->
	<script src="vendor/jquery.easing.js" type="text/javascript"></script>
	<script src="vendor/jquery.back-to-top.js" type="text/javascript"></script>
	<script src="vendor/jquery.smooth-scroll.js" type="text/javascript"></script>
	<script src="vendor/jquery.wow.min.js" type="text/javascript"></script>
	<script src="vendor/swiper/js/swiper.jquery.min.js"
		type="text/javascript"></script>
	<script src="vendor/masonry/jquery.masonry.pkgd.min.js"
		type="text/javascript"></script>
	<script src="vendor/masonry/imagesloaded.pkgd.min.js"
		type="text/javascript"></script>


	<!-- PAGE LEVEL SCRIPTS -->
	<script src="js/layout.min.js" type="text/javascript"></script>
	<script src="js/components/wow.min.js" type="text/javascript"></script>
	<script src="js/components/swiper.min.js" type="text/javascript"></script>
	<script src="js/components/masonry.min.js" type="text/javascript"></script>
	<script src="js/components/google-map.min.js" type="text/javascript"></script>
	<%
		String flag = "";
		String scerror = "";
		flag = (String) request.getAttribute("flag");
		System.out.println("jspflag" + flag);
		if (flag != null) {
			if (flag.equals("1")) {
				scerror = "删除成功。";
				out.print("<script language='javascript'>alert('" + scerror + "');</script>");
			}
			if (flag.equals("0")) {
				scerror = "删除失败。";
				out.print("<script language='javascript'>alert('" + scerror + "');</script>");
			}

		}
		System.out.println(scerror);
	%>
</body>
<!-- END BODY -->
</html>